package com.csx.micrometer.common.config;

import com.csx.micrometer.common.filter.CommonTagsPool;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author cuisongxu
 * @date 2022/12/5 14:48
 */
@EnableConfigurationProperties({MicrometerMetricProperties.class, MicrometerCoordinateProperties.class})
@Configuration
public class MicrometerCommonAutoConfiguration {

    @Bean
    public ApplicationListener<ApplicationEnvironmentPreparedEvent> commonTagsInitApplicationListener() {
        return event -> CommonTagsPool.setMicrometerCoordinateProperties(event.getEnvironment());
    }
}
